﻿<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>实习报告详情</title>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/timecontrol.min.css" />
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<style type="text/css" media="screen">
			.title {
				font-size: 14px;
			}
			.summary_div .feeling {
				padding-bottom: 1px;
			}
			.feeling {
				border-bottom: 1px solid #ededed;
				padding-left: 14px;
			}
			.title {
				border-left: unset;
			}
			.score_div .feeling-text {
				/*text-indent: 2em;*/
				background-size: 16px;
				margin-top: 15px;
				margin: 10px;
			}
			.score_div .feeling-text p {
				color: #646464;
				padding: 2px 2px;
			}
			.bottom_btn_div {
				color: #FFF;
				height: 45px;
				width: 100%;
				z-index: 995;
				border-top: 1px solid #d9d9d9;
				position: fixed;
				bottom: 0px;
				left: 0px;
				text-align: center;
				margin-top: 23px;
			}
			.bottom_btn_div a {
				line-height: 45px;
				font-size: 14px;
				background: #18b4ed;
				width: 100%;
				color: #FFF;
			}
			.content_div {
				margin-top: 66px
			}
			.comment_div {
				padding-right: 20px;
				margin-top: 10px
			}
			.score_div .feeling-text p {
				color: #646464;
				padding: 2px 2px;
			}
			.score_div {
				padding: 2px 5px;
				background: #fff
			}
			.star_score_div {
				padding: 10px;
			}
			.myScore-starscore {
				font-size: 14px;
				color: #646464;
				margin-left: 15px;
			}
			.star_score_div	.myScore-starscore .star img {
				margin-left: 3%;
				width: 18px;
			}
			.star_score_div	.top {
				margin-top: 10px;
			}
			.star {
				width: 67%;
			}
			.left {
				float: left;
			}
			.letter {
				width: 85px;
				line-height: 15px;
				padding: 4px 0px
			}
			.title img {
				height: 20px;
				padding-top: 4px
			}
			.summary_title {
				display: inline-block;
				background: url(../../icon/icon_summary_title.png) no-repeat left center;
				background-size: 20px;
				padding-left: 25px;
				padding-bottom: 0px;
				font-size: 14px;
			}
			.padding25 {
				padding-left: 3px
			}
			.attachment_title {
				display: inline-block;
				background: url(../../icon/icon_attachment.png) no-repeat left center;
				background-size: 20px;
				padding-left: 25px;
			}
			.workname_title {
				display: inline-block;
				background: url(../../icon/icon_workname.png) no-repeat left center;
				background-size: 20px;
				padding-left: 25px;
			}
			.top_title {
				margin-top: 66px
			}
			.writeReport .ReviewWeekly_div {
				margin-top: 0px;
			}
			.attachment_div {
				padding-left: 10px;
				padding-right: 8px;
			}
			.yesorno {
				background: #fff;
				padding: 2px 25px;
				border-bottom: unset;
				border-top: unset;
				margin: 1px 0;
			}
			.yesorno .yesorno-radio {
				margin-top: 5px;
			}
		</style>
	</head>
	<body>
		<div class="base_style_color " id='BarAppearance' style="height: 22px;width: 100%"></div>
		<div class="base_navigation_bar base_style_color base_navigation_item_bar">
			<a class="base_left_item" href="#" onclick="showAlert()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
			<span>实习报告</span>
			<a class="base_right_item base_hide_item" href="#"> </a>
		</div>
		<div class=" writeReport"style="margin-top: 65px">
			<div class="ReviewWeekly_div top_54 summary_div">
				<div class="feeling">
					<p class="title summary_title" >
						结业感想
					</p>
				</div>
				<div class="score_div">
					<div class="feeling-text" style="margin-bottom: -8px">
						<textarea class="textarea_t bottom_10" id="jygx"  placeholder='字数不得少于5个字'></textarea>
					</div>
				</div>
			</div>
			<div class="ReviewWeekly_div  summary_div">
				<div class="feeling">
					<p class="title  attachment_title" >
						附件内容
					</p>
				</div>
				<div class="score_div">
					<div class="fileDiv attachment_div" id="imgDiv" >
						<ul id="ul1" class=""></ul>
					</div>
				</div>
			</div>
			<div class="myScore top_10"  id="dgsx"  style="border-bottom:unset;margin-bottom: 10px" hidden="hidden">
				<p class="title" >
					对企业师傅的评分
				</p>
				<div class="myScore-starscore clearfix">
					<div class="letter left">
						辅导态度：
					</div>
					<div class="star left" id="taiduNum">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png" hidden="hidden">
					</div>
				</div>
				<div class="myScore-starscore clearfix top">
					<div class="letter left">
						辅导频率：
					</div>
					<div class="star left" id="chuqinNum">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png" hidden="hidden">
					</div>
				</div>
				<div class="myScore-starscore clearfix top">
					<div class="letter left">
						技能水平：
					</div>
					<div class="star left" id="gzwcdNum">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png" hidden="hidden">
					</div>
				</div>
				<div class="myScore-starscore clearfix top">
					<div class="letter left">
						培训次数：
					</div>
					<div class="star left" id="jnzwdNum">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png">
						<img src="../../image/icon_xingxing01.png" hidden="hidden">
					</div>
				</div>
			</div>
			<div class="ReviewWeekly_div  summary_div">
				<div class="feeling">
					<p class="title workname_title font14" >
						是否愿意就业到当前实习单位？
					</p>
				</div>
				<div class="score_div">
					<div class="yesorno">
						<div class="mui-input-row mui-radio yesorno-radio">
							<input name="radio1" type="radio"  value='1' >
							<label>是</label>
						</div>
						<div class="mui-input-row mui-radio yesorno-radio" >
							<input name="radio1" type="radio" value='0' >
							<label>否</label>
						</div>
					</div>
				</div>
			</div>
			<button id="sumbit_bt" type="button" class=" top_30 bottom_30  mui-btn btns mui-btn-block  " onclick="UploadData()" disabled="true">
				提交
			</button>
		</div>
		<div id="offlineAlert" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title">是否放弃在此页面操作？</strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="cleanCancel()" href="#" class="weui_btn_dialog default"  style="color:#18b4ed">取消</a>
					<a onclick="cleanConfirm()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
	</body>
	<script src="../../script/mui.min.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script src="../../script/timecontrol.min.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/mui.min.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../script/timeStampTool.js"></script>
	<script src="../../script/processing_images.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/base64.min.js"></script>
	<script type="text/javascript">
		var taiduNum = 0;
		var chuqinNum = 0;
		var gzwcdNum = 0;
		var jnzwdNum = 0;
		var sfyyjy = '';
		var parten = /^\s*$/;
		var SizeArr = [];
		var NameArr = [];
		var FileArr = new Array();
		//附件地址集合
		var urlArr = new Array();
		//上传后的图片路径对象
		var picurls = [];
		//		var str = [];
		var num = 0;
		var str = '';
		var sxtypes = '';
		var arr = new Array('jpg', 'gif', 'png', 'jpeg', 'bmp', 'doc', 'xls', 'ppt', 'docx', 'xlsx', 'pptx', 'pdf', 'txt');
		var FileFormatArr = new Array('doc', 'xls', 'ppt', 'docx', 'xlsx', 'pptx', 'pdf', 'txt');
		var ImgFormatArr = new Array('jpg', 'gif', 'png', 'jpeg', 'bmp');
		var pid = "";
		apiready = function() {
			SendBehaviorTrajectoriesNotifi1('0', '学生端提交实习报告', '098', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title);
			//获取学生实习计划状态
			judgePracticeType();
			//获取评分分数
			setupStarClick();
			//获取是否结果
			yesornoClick();
			backKey();
			//添加附件
			listfile();
		}
		//学生端获取实习计划状态（仅限学生端）
		function judgePracticeType() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjid')
			};
			cfnetppPOST(urlPracticeType, param, true, function(data, status) {
				if (status == 'success') {
					//										alert(JSON.stringify(data));
					//1,成功，返回success
					if (data.status == 1) {
						var list = data.json;
						if (list != null && list != '') {
							sxtypes = parseInt(list.sxtypes);
							pid = list.id;
							//0：顶岗，1：认知，2:跟岗
							if (sxtypes != 1) {
								$('#sumbit_bt').unbind('click').addClass('mui-btn-warning').removeClass('btns').attr('disabled', false);
								if (sxtypes == 0) {
									$('#dgsx').show();
								}
							}
						} else {
							ShowToast('你还未有实习计划，请等待老师分配');
						}
					} else if (data.status == -1) {
						ShowToast('你还未有实习计划，请等待老师分配');
					} else {
						ShowToast('你还未有实习计划，请等待老师分配');
					}
				}
			})
		}

		function listfile() {
			//			$("#ul1").html('');
			var num = FileArr.length;
			var imageHtmls = '';
			var str2 = "支持附件最大附件大小:10M;仅支持以下格式:('jpg', 'gif', 'png', 'jpeg', 'bmp', 'doc', 'xls', 'ppt', 'docx', 'xlsx', 'pptx', 'pdf', 'txt')";
			if (num > 0 && num < 11) {
				for (var i = 0; i < num; i++) {
					var imageHtml = '<li dataid="' + num + '"  class="mui-table-view-cell " >' + '<a class=" base_content_font" href="#" >' + '<span class="base_grey left_text">' + FileArr[i].filename + '</span>' + ' <span id="company_name " class="base_grey right_text padding_left_10">' + bytesToSize(FileArr[i].filesize) + '</span> <img class="  right"    src="../../image/remove.png"  width="20" height="20"  onClick="deleteImg(' + i + ')" >' + '</a>' + '</li>';
					imageHtmls = imageHtmls + imageHtml;
					//					alert(imageHtmls);
				}
			}
			if (num < 10) {
				var seleimg = '<a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_default top_10" onclick="AddFile()">' + '添加附件' + '</a>' + '<span style="margin-left: 5px"class="font11">' + str2 + '</span>' + '</div>';
				imageHtmls = imageHtmls + seleimg;
			}
			$("#ul1").html(imageHtmls);
		}

		//删除附件
		function deleteImg(i) {
			FileArr.splice(i, 1);
			urlArr.splice(i, 1);
			listfile();
		}

		//添加附件
		//添加附件
		//添加附件
		function AddFile() {
			if (api.systemType == "ios") {
				ShowToast('ios暂不支持提交附件，请在pc平台或android平台下提交');
			} else {
				var fileBrowser = api.require('fileBrowser');
				fileBrowser.open(function(ret, err) {
					if (ret) {
						//文件地址
						var url = ret.url;
						fileBrowser.close();
						//文件名
						var fileName = splitFileName(url);
						//文件后缀ming
						var ext = fileName.replace(/.+\./, "");
						//小写格式
						var extLower = ext.toLowerCase();
						////根据文件地址判断文件大小是否超过10M
						var fs = api.require('fs');
						fs.getAttribute({
							path : url
						}, function(ret, err) {
							var fileSize = ret.attribute.size;
							//大小，10M转换为b
							if (ret.attribute.size > 10485760) {
								ShowToast('上传的文件过大');
							} else if (arr.toString().indexOf(extLower) == -1) {
								ShowToast('文件格式不符合要求');
							} else if (urlArr.toString().indexOf(url) > -1) {
								ShowToast('不允许重复提交');
							} else {
								urlArr.push(url);
								var num = urlArr.length;
								var data = {
									filepath : url,
									filename : fileName,
									filesize : fileSize,
								};
								FileArr.push(data);
								listfile();
								if (num > 0) {
									api.showProgress({
										style : 'default',
										animationType : 'fade',
										title : '努力加载中...',
										text : '文件上传中...',
										modal : true
									});
									if (ImgFormatArr.toString().indexOf(extLower) != -1) {//图片格式文件
										//上传图片文件到阿里云
										UploadFile_ali(Upload_File_img, url, function(ret) {
											//判断是否上传完成
											FileArr[num - 1].filepath = ret.fileurl;
											var k = FileArr.length;
											if (k == num) {
												str = FileArr;
												hideProgress();
											}
										});
									} else {//文档格式文件
										//上传文档格式至阿里云
										UploadFile_ali(Upload_File_file, url, function(ret) {
											//判断是否上传完成
											FileArr[num - 1].filepath = ret.fileurl;
											var k = FileArr.length;
											if (k == num) {
												str = FileArr;
												hideProgress();
											}
										});
									}
								} else {
									str = '';
								}
							}
						});
					}
				});
			}
		}

		function UploadData() {
			//			SendBehaviorTrajectoriesNotifi('1', '学生端提交实习报告', '098');
			var jygx = $('#jygx').val();
			if (jygx == "" || sfyyjy == "" || sfyyjy == undefined || parten.test(jygx)) {
				ShowToast('提交信息不完整，请完善信息后再次提交');
			} else if (jygx.length < 5) {
				ShowToast('字数不得小于5个字');
			} else if (jygx.length > 10000) {
				ShowToast('字数不得大于于1万字');
			} else if ((sxtypes == "0" ) && (taiduNum == 0 || chuqinNum == 0 || gzwcdNum == 0 || jnzwdNum == 0)) {
				ShowToast('你还未完成对企业师傅的评分，请评分');
			} else {
				api.showProgress({
					style : 'default',
					animationType : 'fade',
					title : '正在提交',
					text : '请稍候...',
					modal : true
				});
				var params = {
					uid : $api.getStorage('cfnetppuid'),
					jid : $api.getStorage('cfnetppjid'),
					urldata : str,
					comments : Base64.encode(jygx),
					sxtd : taiduNum,
					cql : chuqinNum,
					gzwcd : gzwcdNum,
					jnzwd : jnzwdNum,
					sfyyjy : sfyyjy,
					pid : pid,
					message : '实习报告'
				};
				cfnetppPOST(urlGraduation, params, false, function(data, status) {
					SendBusinessOperationsLogNotifi('学生端提交实习报告', '098', params, params, '', data, '提交实习报告接口', '098-01')
					api.hideProgress();
					var list = data.json;
					if (status == 'success') {
						//1,成功，返回success
						if (data.status == 1) {
							api.toast({
								msg : '提交成功',
								duration : 2000,
								location : 'bottom'
							});
							//提交成功发送通知，实习报告列表开始刷新
							sendNotifi();
							setTimeout(function() {
								api.closeWin();
							}, 1000);
						} else {
							//4,未到提交实习报告时间，返回time
							if (data.status == 4) {
								api.toast({
									msg : '暂不可提交实习报告，请于实习期间最后两周提交！',
									duration : 5000,
									location : 'bottom'
								});
								//2，实习报告已审核
							} else if (data.status == 2) {
								api.toast({
									msg : '你本次实习已经结业啦，不用再提交了!',
									duration : 5000,
									location : 'bottom'
								});
								//3,已提交过实习报告，返回
							} else if (data.status == 3) {
								api.toast({
									msg : '你已提交了实习报告，不可重复提交！',
									duration : 5000,
									location : 'bottom'
								});
								//5.未分配实习,返回end
							} else if (data.status == 5) {
								api.toast({
									msg : '未开始实习，暂不能提交实习报告',
									duration : 5000,
									location : 'bottom'
								});
							} else {
								ShowToast(data.message)
							}
						}
					} else {
						api.toast({
							msg : '网络异常,请检查网络!',
							duration : 2000,
							location : 'bottom'
						});
					}
				});
			}
		}

		//提交实习报告成功发送通知
		function sendNotifi() {
			api.sendEvent({
				name : 'RefreshReportNotifi'
			});
		}

		function setupStarClick() {
			$('.star img').each(function(i) {
				$(this).click(function() {
					$(this).attr('src', '../../image/icon_xingxing.png');
					$(this).prevAll().attr('src', '../../image/icon_xingxing.png');
					$(this).nextAll().attr('src', '../../image/icon_xingxing01.png');
					var score = ($(this).prevAll().length + 1) * 5;
					if ($(this).parent().attr('id') == 'taiduNum') {//实习态度
						taiduNum = score;
					} else if ($(this).parent().attr('id') == 'chuqinNum') {//出勤率
						chuqinNum = score;
					} else if ($(this).parent().attr('id') == 'gzwcdNum') {//工作完成度
						gzwcdNum = score;
					} else if ($(this).parent().attr('id') == 'jnzwdNum') {//技能掌握度
						jnzwdNum = score;
					}
				})
			});
		}

		function yesornoClick() {
			$('.yesorno').click(function() {
				var sfyyjyScore = $("input[type='radio']:checked").val();
				sfyyjy = sfyyjyScore;
			});
		}

		function backKey() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				showAlert();
			});
		}

		function showAlert() {
			var jygxS = $('#jygx').val();
			if (jygxS.length > 0) {
				$('#offlineAlert').show();
			} else {
				backClick();
			}
		}

		function backClick() {
			SendBehaviorTrajectoriesNotifi1('1', '学生端提交实习报告', '098', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title);
			api.closeWin({
			});
		}

		function cleanCancel() {
			$('#offlineAlert').hide();
		}

		//确定
		function cleanConfirm() {
			$('#offlineAlert').hide();
			backClick();
		}
	</script>
</html>